package com.bupt.dao;

import com.bupt.bean.Temperature;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

public interface TemperatureRepository extends JpaRepository<Temperature,String>, JpaSpecificationExecutor<Temperature> {

    @Query(value="SELECT ROUND(AVG(temperature),1)AS avgtemperature,channel_section_id FROM channel_temperature_t WHERE\n" +
            " creat_time BETWEEN  :beginHour AND :stopHour GROUP BY channel_section_id ORDER BY channel_section_id ASC",nativeQuery=true)
    List<Map<String,Object>> findAvgTemperature(@Param("beginHour") String beginHour,@Param("stopHour") String stopHour);
}
